package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVO;
import com.itheima.health.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface UserMapper extends BaseMapper<User> {
        @Select("select  username,password,id from t_user where username = #{username}")
      UserVO findUserByUsername(@Param("username") String username);
       @Select("SELECT  tr.keyword,tr.id " +
               "from  t_role tr , t_user_role  tur " +
               "where  tur.role_id = tr.id " +
               "and tur.user_id = #{id}")
    Set<RoleVO> findRolesByUid(@Param("id") Integer id);

       @Select("SELECT tp.keyword " +
               "FROM t_permission tp , t_role_permission trp  " +
               "WHERE tp.id = trp.permission_id " +
               "and trp.role_id = #{id}")
    Set<Permission> findPermissionByRoleId(@Param("id") Integer id);
}
